<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Validate</title>
<script type="text/javascript">

	function validate_required(field, alertText) {
		
		with (field) {
			if (value == null || value == "") {
				alert(alertText);
				return false;
			} else {
				return true;
			}
		}
	}
	
	function validate_email(field, alertText) {
		
		with (field) {
			atIndex = value.indexOf("@");
			dotIndex = value.lastIndexOf(".");
			if (atIndex < 1 || (dotIndex - atIndex) < 2) {
				alert(alertText);
				return false;
			} else {
				return true;
			}
		}
	}
	
	function validate_form(form) {
		
		with (form) {
			if (validate_required(email, "E-mail must be filled out!") == false) {
				email.focus();
				return false;
			} else {
				return true;
			}
		}
	}
</script>
</head>
<body>
<form action="clock.html" onSubmit="return validate_form(this)" method="post">
Email: <input type="text" name="email" size="30" />
<input type="submit" value="Submit" />
</form>
</body>
</html>